#pragma once

#include <math.h>

struct Vector2D
{
	float x, y;
	Vector2D(): x(0), y(0){}
	Vector2D(int x, int y): x((float)x), y((float)y){}
	Vector2D(float x, float y): x(x), y(y){}

	void add(Vector2D const & p)
	{	x += p.x;	y += p.y; }
	// operator / (float)
	Vector2D quotient(float const & f) const
	{ return Vector2D(x/f, y/f); }

	// operator /= (float)
	void divide(float const & f)
	{	x /= f;	y /= f; }

	void multiply(float const & f)
	{	x *= f; y *= f; }

	Vector2D difference(Vector2D const & p)
	{	return Vector2D(x-p.x, y-p.y);	}

	float getLength()
	{	return sqrt(x*x+y*y); }

	void normalize()
	{	divide(getLength());	}

	void setLength(float const & f)
	{	normalize(); multiply(f); }
};

struct Vector3D
{
	float x, y, z;
	Vector3D(): x(0), y(0), z(0){}
	Vector3D(int x, int y, int z): x((float)x), y((float)y), z((float)z){}
	Vector3D(float x, float y, float z): x(x), y(y), z(z){}

	void add(Vector3D const & p)
	{	x += p.x;	y += p.y; z += p.z; }
	// operator / (float)
	Vector3D quotient(float const & f) const
	{ return Vector3D(x/f, y/f, z/f); }

	// operator /= (float)
	void divide(float const & f)
	{	x /= f;	y /= f; z /= f; }

	void multiply(float const & f)
	{	x *= f; y *= f; z *= f; }

	Vector3D difference(Vector3D const & p)
	{	return Vector3D(x-p.x, y-p.y, z-p.z);	}

	float getLength()
	{	return sqrt(x*x+y*y+z*z); }

	void normalize()
	{	divide(getLength());	}

	void setLength(float const & f)
	{	normalize(); multiply(f); }
};

